/*==================== This runs Fig 1: sensitivity to time period (ending at 2014-2020 March CPS) ==================*/
/*spec =1 is Dube Controls, spec=3 is BMS controls*/

local  dem i.dem_race##i.post2002  i.dem_race#i.pre1988 i.dem_married i.dem_famsize ///
i.dem_nchild i.dem_nchild##i.pre1988 i.dem_educ i.dem_female i.dem_hisp##i.post2002

local a1 year i.state_fips `dem'
local a2 year i.state_fips `dem' c.year##i.state_fips i.year#i.division
local a3 year i.state_fips `dem'

* ur_high_edu wage_high_edu hpi eitc tanf4 snap4 ACA
*
* unemprate statepcgdp
* stateeitcrate statewelfareben

local rhs1 age_* ur gdppc eitc_dube
local rhs2 age_* ur gdppc eitc_dube
local rhs3 age_* hpi ur_high_edu wage_high_edu eitc tanf4 snap4 ACA

local primary

local j .5
* outreg, clear
local thresholdlist 1
local j 1
local spec 3
local d 1
foreach d of numlist 1(1)8 {
foreach spec of numlist 1 3 {
foreach year of numlist 2014(1)2020 {
 
  use "${data1}regready_cps_ipums_84.dta" , clear
 keep if year<=`year'


if `spec' <3  replace contpov = contpov_dube

  cap drop under


  gen under = contpov < `j'
  local q = `j' * 100
  di "Poverty threshold `q'"

  if `d' == 5 reg under lnMW  `rhs`spec'' `a`spec'' [pw=asecwt] if dem`d'==1,  cluster(state_fips)
  else reghdfe under lnMW `rhs`spec''  [pw=asecwt] if dem`d'==1 , a(`a`spec'') cluster(state_fips)
  est save "${est}ster/other/MW1_Yearly_`year'_`spec'_`d'", replace
  
  if `spec'== 3 replace lnMWF1=0
  if `d' == 5 reg under lnMWF1 lnMW lnMWL1 lnMWL2 lnMWL3  `rhs`spec'' `a`spec'' [pw=asecwt] if dem`d'==1,  cluster(state_fips)
  else reghdfe under lnMWF1 lnMW lnMWL1 lnMWL2 lnMWL3 `rhs`spec''  [pw=asecwt] if dem`d'==1 , a(`a`spec'') cluster(state_fips)
  est save "${est}ster/other/MW2_Yearly_`year'_`spec'_`d'", replace
  }
}
}
